﻿-- --------------------------------------------------------
---  create table ---


-- #Table: sys_actor

-- DROP TABLE sys_actor;

CREATE TABLE sys_actor
(
  id_sys_actor character varying(40) NOT NULL,
  code character varying(50),
  "name" character varying(100),
  flag_type smallint,
  flag_disabled smallint,
  flag_deleted smallint,
  remark text,
  created_date date,
  created_userid character varying(40),
  updated_date date,
  updated_userid character varying(40),
  owned_userid character varying(40),  
  CONSTRAINT sys_actor_pk PRIMARY KEY (id_sys_actor)
)
WITH (
  OIDS=FALSE
);


-- #Table: sys_user

-- DROP TABLE sys_user;
CREATE TABLE sys_user
(
  id_sys_actor character varying(40) NOT NULL,
  "password" character varying(100),
  email character varying(100),
  qq character varying(100),
  mobilephone character varying(100),
  officephone character varying(100),
  expired_date date,
  CONSTRAINT sys_user_pk PRIMARY KEY (id_sys_actor)
)
WITH (
  OIDS=FALSE
);


-- #Table: sys_role

-- DROP TABLE sys_role;

CREATE TABLE sys_role
(
  id_sys_role character varying(40) NOT NULL,
  code character varying(50),
  "name" character varying(100),
  flag_disabled smallint,
  flag_deleted smallint,
  remark text,
  "role" character varying(50) NOT NULL DEFAULT 'admin'::character varying,
  treemap text,
  created_date date,
  created_userid character varying(40),
  updated_date date,
  updated_userid character varying(40),
  owned_userid character varying(40),  
  CONSTRAINT sys_role_pk PRIMARY KEY (id_sys_role)
)
WITH (
  OIDS=FALSE
);


-- #Table: sys_resource

-- DROP TABLE sys_resource;

CREATE TABLE sys_resource
(
  id_sys_resource character varying(40) NOT NULL,
  code character varying(100),
  module_id character varying(200),
  remark text,
  flag_deleted smallint,
  flag_disabled smallint,
  classname character varying(200),
  locked smallint,	
  created_date date,
  created_userid character varying(40),
  updated_date date,
  updated_userid character varying(40),
  owned_userid character varying(40),  
  CONSTRAINT sys_resource_pk PRIMARY KEY (id_sys_resource)
)
WITH (
  OIDS=FALSE
);


-- #Table: sys_permission

-- DROP TABLE sys_permission;

CREATE TABLE sys_permission
(
  id_sys_permission character varying(40) NOT NULL,
  id_sys_role character varying(40) NOT NULL,
  id_sys_resource character varying(40) NOT NULL,
  access_control character varying(200) NOT NULL,
  auth_started_date date,
  auth_end_date date,
  CONSTRAINT sys_permission_pk PRIMARY KEY (id_sys_role, id_sys_resource)
)
WITH (
  OIDS=FALSE
);


-- #Table: sys_binding_action

-- DROP TABLE sys_binding_action;

CREATE TABLE sys_binding_action
(
  id_sys_binding_action character varying(40) NOT NULL,
  id_resource character varying(40) NOT NULL,
  "action" character varying(200) NOT NULL,
  CONSTRAINT sys_binding_action_pk PRIMARY KEY (id_sys_binding_action)
)
WITH (
  OIDS=FALSE
);


CREATE TABLE sys_menu_resource
(
  id_resource character varying(40) NOT NULL,
  menu_level smallint NOT NULL DEFAULT 0,
  parent_id character varying(40),
  function_id character varying(40),
  "name" character varying(200),
  flag_disabled smallint NOT NULL DEFAULT 0,
  act character varying(100),
  tree_map text,
  CONSTRAINT sys_menu_resource_pk PRIMARY KEY (id_resource)
)
WITH (
  OIDS=FALSE
);


-- #Table: sys_module_function_resource

-- DROP TABLE sys_module_function_resource;

CREATE TABLE sys_module_function_resource
(
  id_resource character varying(40) NOT NULL,
  "name" character varying(100),
  id_sys_module character varying(40) NOT NULL,
  CONSTRAINT sys_module_function_resource_pk PRIMARY KEY (id_resource)
)
WITH (
  OIDS=FALSE
);


-- #Table: sys_module_resource

-- DROP TABLE sys_module_resource;

CREATE TABLE sys_module_resource
(
  id_resource character varying(40) NOT NULL,
  "name" character varying(200),
  "version" character varying(100),
  developer character varying(100),
  release_date date,
  group_id character varying,
  CONSTRAINT sys_module_resource_pk PRIMARY KEY (id_resource)
)
WITH (
  OIDS=FALSE
);



-- #Table: sys_url_resource

-- DROP TABLE sys_url_resource;

CREATE TABLE sys_url_resource
(
  id_resource character varying(40) NOT NULL,
  link character varying(200),
  function_id character varying(40),
  "type" character varying(50),
  CONSTRAINT sys_url_resource_pk PRIMARY KEY (id_resource)
)
WITH (
  OIDS=FALSE
);



-- #Table: map_actor_role

-- DROP TABLE map_actor_role;

CREATE TABLE map_actor_role
(
  id_sys_actor character varying(40) NOT NULL,
  id_sys_role character varying(40) NOT NULL,
  CONSTRAINT map_actor_role_pk PRIMARY KEY (id_sys_actor, id_sys_role)
)
WITH (
  OIDS=FALSE
);


-- #Table: map_role_hierarchy

-- DROP TABLE map_role_hierarchy;

CREATE TABLE map_role_hierarchy
(
  id_role_inheritance character varying(40) NOT NULL,
  id_role_dependence character varying(40) NOT NULL,
  CONSTRAINT map_role_hierarchy_pk PRIMARY KEY (id_role_inheritance, id_role_dependence)
)
WITH (
  OIDS=FALSE
);